﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EShop.BussinessObjects;

namespace EShop.BusinessLogic
{
    public class CBLProduct
    {
        public static Decimal CurrentPrice(Product product)
        {
            Decimal _price = product.Price;
            if (product.IsHappyHourActive)
            {
                if (product.HappyHourDays.Substring((int)DateTime.Now.DayOfWeek - 1, 1) == "1")
                {
                    if ((product.HappyHourFrom.Value.TimeOfDay.TotalSeconds <= DateTime.Now.TimeOfDay.TotalSeconds) &&
                        (product.HappyHourTo.Value.TimeOfDay.TotalSeconds >= DateTime.Now.TimeOfDay.TotalSeconds))
                    {
                        _price = product.HappyHourPrice.Value;
                    }
                }
            }
            if (product.IsDiscount)
            {
                _price -= product.DiscountPrice.Value;
            }
            return _price;
        }
    }
}
